<?php

/**
 * 系统引导文件
 *
 * @package    01CMS
 * @subpackage system
 * @author     rolong at vip.qq.com
 * @version    1.0.0
 * @link       http://www.01cms.com
 */

if (! defined('SYS_PATH'))
{
    exit('SYS_PATH ERROR');
}

try
{
    require (SYS_PATH . '/lib/Load.php');
    
    $Load = new Load();
    
    require (SYS_PATH . '/common.php');
    require (SYS_PATH . '/lib/Uri.php');
    require (SYS_PATH . '/lib/Base.php');
    require (SYS_PATH . '/lib/Controller.php');
    
    $Uri = lib('Uri');
    
    $c = $Uri->getClassName();
    $m = $Uri->getMethodName();
    $p = $Uri->getParam();
    
    $controllerName = $c . 'Controller';
    
    if (! file_exists(APP_PATH . '/controller/' . $controllerName . '.php'))
    {
        throw new Exception('您访问的页面不存在');
    }
    else
    {
        require (APP_PATH . '/controller/' . $controllerName . '.php');
    }
    
    if (class_exists($controllerName, FALSE))
    {
        $Controller = new $controllerName();
        
        if (method_exists($Controller, $m) && ! empty($m))
        {
            call_user_func_array(array($Controller, $m), $p);
        }
        else
        {
            throw new Exception('您访问的页面不存在');
        }
    }
    else
    {
        throw new Exception('您访问的页面不存在');
    }
}
catch (Exception $e)
{
    $message = '<span class="error">' . $e->getMessage() . '</span>';
    include SYS_PATH . '/view/error.php';
}

/* End of file /01CMS/01mvc/boot.php */